package wang.shuzhu;

import java.util.Random;

public class lianxi4 {
    public static void main(String[] args) {
        int[] arr = new int[5];
        for (int i = 0; i < 5; i++) {
            arr[i] = i + 1;
            System.out.println("i = " + arr[i]);
        }
        Random ran=new Random();
        int temp;
        for (int i = 0; i < 5; i++) {
            int random= ran.nextInt(5);
            temp=arr[i];
            arr[i]=arr[random];
            arr[random]=temp;
            System.out.println("random = " + random);
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.println("arr = " + arr[i]);
        }

    }


}



    /*int arr[] = {1, 2, 3, 4, 5};

    Random r = new Random();
        for (int i = 0; i < 5; i++) {

        int a = r.nextInt(5);
//            int b = r.nextInt(5);

        int tem = arr[i];
        arr[i] = arr[a];
        arr[a] = tem;


        }
        for (int i = 0; i < arr.length; i++) {
        System.out.println(arr[i]);
        }
     *//*   for (int i : arr) {
            System.out.println("i = " + i);
        }*//*
//        System.out.println(Arrays.toString(arr));
*/
